<template>
    <div>
        <PageTitle >
            <i class="appIcon" v-html="auditIcon"></i>
            <h1>Audits</h1>
        </PageTitle>

        <SummaryBar :summaryData="summary"></SummaryBar>

        <div class="row">
            <div  class="col-medium-1-1">
                <Panel>
                    <table v-if="recentItems">
                        <tr>
                            <th width="25%">Recent Item ID</th>
                            <th width="50%">Name</th>
                            <th width="25%">Last Access</th>
                        </tr>
                        <tr v-for="item in recentItems">
                            <td><a href="#">{{item.id}}</a></td>
                            <td>{{item.name}}</td>
                            <td>{{item.lastAccess}}</td>
                        </tr>

                    </table>
                    <div class="no-data" v-else>
                        <img class="no-data__checkmark" src="../../assets/img/check.png">
                        <p class="no-data__title">No Recent Items!</p>
                    </div>
                </Panel>
            </div>

        </div>
    </div>
</template>
<script>
    import axios from 'axios'
    import Panel from './Panel.vue'
    import PageTitle from './PageTitle.vue'
    import SummaryBar from './SummaryBar.vue'

    export default {
        components:{
            Panel,
            PageTitle,
            SummaryBar
        },
        data() {
            return {
                asset: null,
                systems: null,
                recentItems : null,
                summary: [
                    {
                        "Physical Assets" : "822",
                        "Audited Assets": "14%"
                    },
                    {
                        "Audits" : "6",
                        "Investigation & Diagnosis": "2,249"
                    },
                    {
                        "Solutions" : "1,922",
                        "Total Annual Savings": "$5.27M"
                    }
                ],
                auditIcon: require('../../assets/img/Audits-Icon.svg'),

            }
        },

        mounted: function() {
            var self = this;
            axios.get(process.env.API_ROOT + '/recentItems', {
            }).then(function(response) {
                self.recentItems = response.data;
            });
        }



    }
</script>